# Properly indents a line for the original Kernighan & Richie C
# Left braces may go on their own lines.
setmacro KRC-indent 0 (indent . -255 first ifelse c="{" (up firstnb set m (\$colno) down) Mc-g Mcs-2)
# This calculates which column a line should begin on.
setmacro c-getcol 0 (set m 1 do (when c="#" nop when c="else" c-else when c="}" Mc-2 Mc-f if 5 (ping 9 wleft ifelse c="else" Mcs-0 (last left do (when c=41 Mcs-0 when c="," Mc-, Mc-;)))))
map Mc-g (set m 1 if c<>"#" (ifelse c="else" Mc-e (ifelse c="}" Mc-2 (Mc-f if 5 (ping 9 wleft ifelse c="else" Mcs-0 (last left ifelse c=41 Mcs-0 (ifelse c="," Mc-, Mc-;)))))))
# This sets the indentation mark one tab length forward.
map Mcs-0 (firstnb tab set m (\$colno) pong 9)
map Mc-; (pong 9 insert (}) left force s match sc-l if c="{" (force s firstnb if c="switch" (force s tab) set m (\\\$colno) pong 9) del add m 4 last if !l (left if c=":" (sub m 4)) pong 9)
map Mc-, (pong 9 insert (}) left force s match sc-l if c="{" (force s firstnb if c="switch" (force s tab) tab set m (\\\$colno) pong 9) del add m 4 last if !l (left if c=":" (sub m 4)) pong 9)
# If the line isn't blank, this checks whether a left brace reigns
# over the current line. Toggle 5 is reset if one doesn't, which
# will usually be for comments in the preprocessor code.
map Mc-f (flag 5 1 if !r (insert (}) left force s match ifelse c="{" (force s match) (flag 5 0) del))
#map Mcs-2 (ifelse r (col (\$m)) (split col (\$m) join))
# This does the actual indenting after it is determined which column